<?php

/**
 * 调用services的类
 * Class Fend_Services_Helper
 */
class Fend_Service_Helper extends Fend
{
//调用service的方法
    public static function invoke($service = '', $serviceFunction = '', $params = array())
    {
        try {
            $result = $service::factory()->{$serviceFunction}(...$params);
            return new Fend_Service_Result($result);
        } catch ( Exception $e ) {
            $code = $e->getCode();
            if ( $code == 1 ) {
                $code = -1;
            }
            return new Fend_Service_Result(array("stat" => $code, "msg" => $e->getMessage(), "data" => array(), "backtrace" => $e->getTraceAsString()));
        }
    }

    public static function isOk($result)
    {
        return isset($result["stat"]) && $result["stat"] == 1 ? true : false;
    }

}